package edu.jd.movieplatform.c_admin.hall;

import edu.jd.movieplatform.common.CommonService;
import edu.jd.movieplatform.common.CurrentManager;
import edu.jd.movieplatform.common.MTokenUtils;
import edu.jd.movieplatform.common.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/c_admin/hall")
public class C_HallAPI {

    @Resource
    private c_HallService cHallService;

    @Resource
    private CommonService commonService;

    @GetMapping("")
    public Result hallList(c_HallDto dto,@RequestHeader("Token") String token){
        CurrentManager currentManager = MTokenUtils.getUserInfo(token,commonService);
        dto.setM_id(currentManager.getM_id());
        Map<String,Object> page = cHallService.getHallList(dto);
        return Result.success(page);
    }

    @PostMapping("")
    public Result hallAdd(@RequestBody c_HallDto dto){
        cHallService.addHall(dto);
        return Result.success();
    }

    @PutMapping("")
    public Result hallUpd(@RequestBody c_HallDto dto){
        cHallService.updHall(dto);
        return Result.success();
    }

    @DeleteMapping("")
    public Result hallDel(@RequestBody c_HallDto dto){
        cHallService.delHall(dto);
        return Result.success();
    }
}
